﻿using System;
using System.Globalization;
using System.Resources;
using System.Threading;
using System.Windows.Forms;
using CustomUIControls;
using HRM.Common;
using System.Runtime.CompilerServices;

namespace HRM
{
    static class Program
    {
        public static Form frmMain;
        public static bool isAdmin = false;
        public static bool isViewAll = false;
        public static bool isChuyenQuan = false;
        public static string strUserName = "";
        public static string strPassword = "";
        public static int intBranchID = 0;
        public static string strBranch = "";
        public static string strBranchAddress = "";
        public static string strBranchRepName = "";
        public static string strBranchPhone = "";
        public static string strBranchFax = "";
        public static string strBranchRepPos = "";
        public static string strBranchCode= "";
        public static string strBranchBHXH = "";

        public static string strBranchBankAccount = "";
        public static string strBranchBankName = "";
        public static string strBranchEmail = "";

        public static string strInsurancePlace = "";
        public static string strInsuranceLevel = "";
        public static string strRegionCode = "";
        public static string strLanguage = "vi";
        public static string ProjectName = "SIS - Quản lý nghiệp vụ BHXH doanh nghiệp";
        public static string CompanyName = "Công Ty Phần mềm và In Phú Hải";
        public static int Version = 10576;
        public static int TotalEmployee = 0;
        public static int TotalProbation = 0;
        public static int TotalIncreaseSalary = 0;
        public static int TotalUpdatePos = 0;
        public static int intInsType = 0;
        public static readonly string VersionDate = @"12/09/2015";    
        public static TaskbarNotifier taskbarNotifier;
        public static ResourceManager m_ResourceManager = new ResourceManager("HRM.Localization",System.Reflection.Assembly.GetExecutingAssembly());
        public static CultureInfo m_VietnameseCulture = new CultureInfo("vi-VN");
        public static CultureInfo m_EnglishCulture = new CultureInfo("en-US");

        private static Mutex m;
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        /// 


        [STAThread]
        static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                bool ok;

                //The name used when creating the mutex can be any string you want
                m = new Mutex(true, "HRM", out ok);

                if (!ok)
                {
                    MessageBox.Show("Chương trình đang chạy", UIParamater.TitleProject, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                GC.KeepAlive(m);
                strLanguage = Properties.Settings.Default.Language;
                Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
                
                FormGlobals.App_Init();

                Application.Run(new frmMain());
                //Application.Run(new frmDepartmentList2());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            try
            {
                MessageBox.Show("Lỗi xảy ra:\n" + e.Exception.Message + "\nVui lòng ghi lại và báo cho nhân viên hỗ trợ kỹ thuật.",  UIParamater.TitleProject);

            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi xảy ra" + ":\n"+ex.Message+"\n" + "----------------\nVui lòng ghi lại và thông báo cho nhân viên hỗ trợ kỹ thuật.",  UIParamater.TitleProject);
            }
        }
    }
    
}
